Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Ravi Vishwakarma
23-Mar-2026A View in SQL is a virtual table created from a SQL query. Unlike a real table, a view does not store data physically inside the database. Instead, it stores a SELECT statement and shows the result whenever the view is used. Because of this, a view is also called a saved query. Views are useful when we want to simplify complex queries, restrict access to certain columns, or reuse the same query multiple times.
What is a View?
A view is created using the
CREATE VIEWstatement. When we select data from a view, SQL runs the query stored inside the view and returns the result.Example:
Now we can use the view like a table:
The data shown in the view always comes from the original table, so if the table data changes, the view result also changes.
Why we use View
Views are used for many reasons in real projects:
Example of hiding salary:
Users can see only Id and Name, not Salary.
View with Condition
We can create a view with a WHERE condition.
This view will show only employees with high salary.
View with Join
A view can also be created using multiple tables.
This type of view is called a complex view.
Types of View
There are two main types of views.
Simple View
Complex View
Example simple view:
Example complex view:
Update View
We can change a view using ALTER.
Delete View
Can we insert or update in View?
Yes, but only when the view is simple.
Allowed when:
Example:
When to use View
Use view when:
Conclusion
Views are very important in SQL because they make queries reusable, improve security, and simplify database access. In real-world applications, views are often used in reporting, dashboards, and user-level data access. Understanding views is important for SQL interviews and real projects.